//
//  NormalDismissAnimation.m
//  VCTransitionDemo
//
//  Created by 赵国腾 on 16/4/26.
//  Copyright © 2016年 赵国腾. All rights reserved.
//

#import "NormalDismissAnimation.h"

@implementation NormalDismissAnimation

- (CGFloat)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
    
    return 0.6;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {

    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    
    CGRect initialFrame = [transitionContext initialFrameForViewController:fromVC];
    CGRect finishFrame = CGRectOffset(initialFrame, 0, initialFrame.size.height);
    CGFloat d = [self transitionDuration:transitionContext];
    
//    UIView *containerView = [transitionContext containerView];
//    [fromVC.view removeFromSuperview];
    
    [UIView animateWithDuration:d animations:^{
       
        fromVC.view.frame = finishFrame;
    }completion:^(BOOL finished) {
        [transitionContext completeTransition:YES];
    }];
    
}

@end
